From 5d92569378fbee71bb358ee287b6219fb6e1cd23 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Mon, 22 Aug 2005 12:31:08 +0000 Subject: [PATCH] BablPixelFormat cleanup --- ChangeLog | 7 +++++++ babl/babl-classes.h | 2 +- babl/babl-fish.c | 12 ++++++------ babl/babl-format.c | 31 +++++++++++++++---------------- babl/babl-pixel-format.c | 31 +++++++++++++++---------------- tests/babl-html-dump.c | 2 +- 6 files changed, 45 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1e7821..3550555 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-08-22 Øyvind Kolås + + * babl/babl-classes.h: (BabPixelFormat): only a single BablModel. + * babl/babl-fish.h, + * babl/babl-pixel-format.h, + * tests/babl-html-dump.c: accomodate change. + 2005-08-21 Øyvind Kolås * docs/.cvsignore: added Makefile and Makefile.in diff --git a/babl/babl-classes.h b/babl/babl-classes.h index 2ac7b94..d834268 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -173,7 +173,7 @@ typedef struct BablConversion **to; /*< NULL terminated list of conversions to class */ int bands; int planar; - BablModel **model; + BablModel *model; BablComponent **component; BablType **type; BablSampling **sampling; diff --git a/babl/babl-fish.c b/babl/babl-fish.c index fdb06a2..3be6b33 100644 --- a/babl/babl-fish.c +++ b/babl/babl-fish.c @@ -146,14 +146,14 @@ babl_fish_reference_new (Babl *source, babl->reference_fish.model_to_rgba = babl_conversion_find ( - source->pixel_format.model[0], + source->pixel_format.model, babl_model_id (BABL_RGBA) ); babl->reference_fish.rgba_to_model = babl_conversion_find ( babl_model_id (BABL_RGBA), - destination->pixel_format.model[0] + destination->pixel_format.model ); babl->reference_fish.double_to_type = @@ -169,14 +169,14 @@ babl_fish_reference_new (Babl *source, babl->reference_fish.model_to_rgba = babl_conversion_find ( - source->pixel_format.model[0], + source->pixel_format.model, babl_model_id (BABL_RGBA) ); babl->reference_fish.rgba_to_model = babl_conversion_find ( babl_model_id (BABL_RGBA), - destination->pixel_format.model[0] + destination->pixel_format.model ); babl->reference_fish.double_to_type = @@ -256,7 +256,7 @@ babl_fish_process (Babl *babl, /* calculate planar representation of fooA, and fooB */ - imageA = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.source)) -> pixel_format.model[0])); + imageA = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.source)) -> pixel_format.model)); imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA)); /* transform fooA into fooB fooB is rgba double */ @@ -275,7 +275,7 @@ babl_fish_process (Babl *babl, /* transform fooB into fooC fooC is ???? double */ imageB = babl_image_new_from_linear (fooB, babl_model_id (BABL_RGBA)); - imageC = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.destination))->pixel_format.model[0])); + imageC = babl_image_new_from_linear (fooA, BABL(BABL((babl->fish.destination))->pixel_format.model)); babl->reference_fish.rgba_to_model->function.planar( imageB->image.bands, diff --git a/babl/babl-format.c b/babl/babl-format.c index a64349a..d10fb5a 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -44,7 +44,7 @@ pixel_format_new (const char *name, int id, int planar, int bands, - BablModel **model, + BablModel *model, BablComponent **component, BablSampling **sampling, BablType **type) @@ -55,15 +55,13 @@ pixel_format_new (const char *name, /* allocate all memory in one chunk */ babl = babl_calloc (sizeof (BablPixelFormat) + strlen (name) + 1 + - sizeof (BablModel*) * (bands+1) + sizeof (BablComponent*) * (bands+1) + sizeof (BablSampling*) * (bands+1) + sizeof (BablType*) * (bands+1) + sizeof (int) * (bands+1) + sizeof (int) * (bands+1),1); - babl->pixel_format.model = ((void *)babl) + sizeof (BablPixelFormat); - babl->pixel_format.component = ((void *)babl->pixel_format.model) + sizeof (BablModel*) * (bands+1); + babl->pixel_format.component = ((void *)babl) + sizeof (BablPixelFormat); babl->pixel_format.type = ((void *)babl->pixel_format.component) + sizeof (BablComponent*) * (bands+1); babl->pixel_format.sampling = ((void *)babl->pixel_format.type) + sizeof (BablType*) * (bands+1); babl->instance.name = ((void *)babl->pixel_format.sampling) + sizeof (BablSampling*) * (bands+1); @@ -72,17 +70,16 @@ pixel_format_new (const char *name, babl->instance.id = id; strcpy (babl->instance.name, name); - babl->pixel_format.bands = bands; - babl->pixel_format.planar = planar; + babl->pixel_format.model = model; + babl->pixel_format.bands = bands; + babl->pixel_format.planar = planar; for (band=0; band < bands; band++) { - babl->pixel_format.model[band] = model[band]; babl->pixel_format.component[band] = component[band]; babl->pixel_format.type[band] = type[band]; babl->pixel_format.sampling[band] = sampling[band]; } - babl->pixel_format.model[band] = NULL; babl->pixel_format.component[band] = NULL; babl->pixel_format.type[band] = NULL; babl->pixel_format.sampling[band] = NULL; @@ -99,14 +96,13 @@ babl_pixel_format_new (const char *name, int id = 0; int planar = 0; int bands = 0; - BablModel *model [BABL_MAX_BANDS]; + BablModel *model = NULL; BablComponent *component [BABL_MAX_BANDS]; BablSampling *sampling [BABL_MAX_BANDS]; BablType *type [BABL_MAX_BANDS]; BablSampling *current_sampling = (BablSampling*) babl_sampling (1,1); BablType *current_type = (BablType*) babl_type_id (BABL_U8); - BablModel *current_model = NULL; const char *arg = name; va_start (varg, name); @@ -129,12 +125,11 @@ babl_pixel_format_new (const char *name, current_type = (BablType*) babl; break; case BABL_COMPONENT: - if (!current_model) + if (!model) { babl_log ("%s(): no model specified before component %s", __FUNCTION__, babl->instance.name); } - model [bands] = current_model; component [bands] = (BablComponent*) babl; type [bands] = current_type; sampling [bands] = current_sampling; @@ -150,7 +145,12 @@ babl_pixel_format_new (const char *name, current_sampling = (BablSampling*)arg; break; case BABL_MODEL: - current_model = (BablModel*)arg; + if (model) + { + babl_log ("%s(%s): model %s already requested", + __FUNCTION__, babl->instance.name, model->instance.name); + } + model = (BablModel*)arg; break; case BABL_INSTANCE: case BABL_PIXEL_FORMAT: @@ -198,9 +198,8 @@ babl_pixel_format_new (const char *name, babl = pixel_format_new (name, id, - planar, - bands, - model, component, sampling, type); + planar, bands, model, + component, sampling, type); if (db_insert (babl) == babl) diff --git a/babl/babl-pixel-format.c b/babl/babl-pixel-format.c index a64349a..d10fb5a 100644 --- a/babl/babl-pixel-format.c +++ b/babl/babl-pixel-format.c @@ -44,7 +44,7 @@ pixel_format_new (const char *name, int id, int planar, int bands, - BablModel **model, + BablModel *model, BablComponent **component, BablSampling **sampling, BablType **type) @@ -55,15 +55,13 @@ pixel_format_new (const char *name, /* allocate all memory in one chunk */ babl = babl_calloc (sizeof (BablPixelFormat) + strlen (name) + 1 + - sizeof (BablModel*) * (bands+1) + sizeof (BablComponent*) * (bands+1) + sizeof (BablSampling*) * (bands+1) + sizeof (BablType*) * (bands+1) + sizeof (int) * (bands+1) + sizeof (int) * (bands+1),1); - babl->pixel_format.model = ((void *)babl) + sizeof (BablPixelFormat); - babl->pixel_format.component = ((void *)babl->pixel_format.model) + sizeof (BablModel*) * (bands+1); + babl->pixel_format.component = ((void *)babl) + sizeof (BablPixelFormat); babl->pixel_format.type = ((void *)babl->pixel_format.component) + sizeof (BablComponent*) * (bands+1); babl->pixel_format.sampling = ((void *)babl->pixel_format.type) + sizeof (BablType*) * (bands+1); babl->instance.name = ((void *)babl->pixel_format.sampling) + sizeof (BablSampling*) * (bands+1); @@ -72,17 +70,16 @@ pixel_format_new (const char *name, babl->instance.id = id; strcpy (babl->instance.name, name); - babl->pixel_format.bands = bands; - babl->pixel_format.planar = planar; + babl->pixel_format.model = model; + babl->pixel_format.bands = bands; + babl->pixel_format.planar = planar; for (band=0; band < bands; band++) { - babl->pixel_format.model[band] = model[band]; babl->pixel_format.component[band] = component[band]; babl->pixel_format.type[band] = type[band]; babl->pixel_format.sampling[band] = sampling[band]; } - babl->pixel_format.model[band] = NULL; babl->pixel_format.component[band] = NULL; babl->pixel_format.type[band] = NULL; babl->pixel_format.sampling[band] = NULL; @@ -99,14 +96,13 @@ babl_pixel_format_new (const char *name, int id = 0; int planar = 0; int bands = 0; - BablModel *model [BABL_MAX_BANDS]; + BablModel *model = NULL; BablComponent *component [BABL_MAX_BANDS]; BablSampling *sampling [BABL_MAX_BANDS]; BablType *type [BABL_MAX_BANDS]; BablSampling *current_sampling = (BablSampling*) babl_sampling (1,1); BablType *current_type = (BablType*) babl_type_id (BABL_U8); - BablModel *current_model = NULL; const char *arg = name; va_start (varg, name); @@ -129,12 +125,11 @@ babl_pixel_format_new (const char *name, current_type = (BablType*) babl; break; case BABL_COMPONENT: - if (!current_model) + if (!model) { babl_log ("%s(): no model specified before component %s", __FUNCTION__, babl->instance.name); } - model [bands] = current_model; component [bands] = (BablComponent*) babl; type [bands] = current_type; sampling [bands] = current_sampling; @@ -150,7 +145,12 @@ babl_pixel_format_new (const char *name, current_sampling = (BablSampling*)arg; break; case BABL_MODEL: - current_model = (BablModel*)arg; + if (model) + { + babl_log ("%s(%s): model %s already requested", + __FUNCTION__, babl->instance.name, model->instance.name); + } + model = (BablModel*)arg; break; case BABL_INSTANCE: case BABL_PIXEL_FORMAT: @@ -198,9 +198,8 @@ babl_pixel_format_new (const char *name, babl = pixel_format_new (name, id, - planar, - bands, - model, component, sampling, type); + planar, bands, model, + component, sampling, type); if (db_insert (babl) == babl) diff --git a/tests/babl-html-dump.c b/tests/babl-html-dump.c index 55a1660..573d113 100644 --- a/tests/babl-html-dump.c +++ b/tests/babl-html-dump.c @@ -110,7 +110,7 @@ pixel_format_html (Babl *babl) } printf (""); printf (""); - printf ("%s", BABL(babl->pixel_format.model[0])->instance.name ); + printf ("%s", BABL(babl->pixel_format.model)->instance.name ); printf (""); printf (""); for (i=0; i< babl->pixel_format.bands; i++) -- 2.30.2